//////////////////////////////////////////////////////////////////////////
#pragma once
#pragma managed
//////////////////////////////////////////////////////////////////////////
using namespace System;
using namespace System::Runtime::InteropServices;
//////////////////////////////////////////////////////////////////////////
#include "CxCore.Enums.h"
#include "CvStructs.h"
//////////////////////////////////////////////////////////////////////////
NAMESPACE_BEGIN
//////////////////////////////////////////////////////////////////////////
/// <summary>
/// NArrayIterator
/// </summary>
[StructLayoutAttribute(LayoutKind::Sequential)]
public value struct NArrayIterator
{
	/// <summary>
	/// number of arrays
	/// </summary>
	int count;
	/// <summary>
	/// number of dimensions to iterate
	/// </summary>
	int dims;
	/// <summary>
	/// maximal common linear size: { width = size, height = 1 };
	/// </summary>
	Size2D32s size;
	/// <summary>
	/// pointers to the array slices
	/// </summary>
	inline_array_ex<IntPtr, sizeof(size_t), CV_MAX_ARR> ptr;
	/// <summary>
	/// for internal use
	/// </summary>
	inline_array<int, CV_MAX_DIM> stack;
	/// <summary>
	/// pointers to the headers of the
	/// matrices that are processe
	/// </summary>
	inline_array_ex<IntPtr, sizeof(size_t), CV_MAX_ARR> hdr;
};

/// <summary>
/// GraphScanner
/// </summary>
[StructLayoutAttribute(LayoutKind::Sequential)]
public value struct GraphScanner
{
	/// <summary>
	/// current graph vertex (or current edge origin)
	/// </summary>
	IntPtr vtx;
	/// <summary>
	/// current graph edge destination vertex
	/// </summary>
	IntPtr dst;
	/// <summary>
	/// current edge
	/// </summary>
	IntPtr edge;
	/// <summary>
	/// the graph
	/// </summary>
	IntPtr graph;
	/// <summary>
	/// the graph vertex stack
	/// </summary>
	IntPtr stack;
	/// <summary>
	/// the lower bound of certainly visited vertices
	/// </summary>
	int index;
	/// <summary>
	/// event mas
	/// </summary>
	int mask;
};

/// <summary>
/// Font value structure
/// </summary>
[StructLayoutAttribute(LayoutKind::Sequential)]
public value struct Font
{
	/// <summary>
	/// =CV_FONT_*
	/// </summary>
	FontFlag font_face;
	/// <summary>
	/// font data and metrics
	/// </summary>
	IntPtr ascii;
	IntPtr greek;
	IntPtr cyrillic;
	float hscale;
	float vscale;
	/// <summary>
	/// slope coefficient: 0 - normal, >0 - italic
	/// </summary>
	float shear;
	/// <summary>
	/// letters thickness
	/// </summary>
	int thickness;
	/// <summary>
	/// horizontal interval between letters
	/// </summary>
	float dx;
	int line_type;
};

/// <summary>
/// Iteration through the sequence tree
/// </summary>
[StructLayoutAttribute(LayoutKind::Sequential)]
public value struct TreeNodeIterator
{
	IntPtr node;
	int level;
	int max_level;
};

/// <summary>
/// CmpFunc
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <param name="userdata"></param>
/// <returns></returns>
[UnmanagedFunctionPointerAttribute(CallingConvention::Cdecl)]
public delegate int CmpFunc(IntPtr a, IntPtr b, IntPtr userdata );

/// <summary>
/// ErrorCallback
/// </summary>
/// <param name="status"></param>
/// <param name="func_name"></param>
/// <param name="err_msg"></param>
/// <param name="file_name"></param>
/// <param name="line"></param>
/// <param name="userdata"></param>
/// <returns></returns>
[UnmanagedFunctionPointerAttribute(CallingConvention::Cdecl)]
public delegate int ErrorCallback(int status, IntPtr func_name, IntPtr err_msg, IntPtr file_name, int line, IntPtr userdata);

/// <summary>
/// AllocFunc
/// </summary>
/// <param name="size"></param>
/// <param name="userdata"></param>
/// <returns></returns>
[UnmanagedFunctionPointerAttribute(CallingConvention::Cdecl)]
public delegate IntPtr AllocFunc(size_t size, IntPtr userdata);

/// <summary>
/// FreeFunc
/// </summary>
/// <param name="pptr"></param>
/// <param name="userdata"></param>
/// <returns></returns>
[UnmanagedFunctionPointerAttribute(CallingConvention::Cdecl)]
public delegate int FreeFunc(IntPtr pptr, IntPtr userdata);

/// <summary>
/// IplCreateImageHeader
/// </summary>
/// <param name="nChannels"></param>
/// <param name="alphaChannel"></param>
/// <param name="depth"></param>
/// <param name="colorModel"></param>
/// <param name="channelSeq"></param>
/// <param name="dataOrder"></param>
/// <param name="origin"></param>
/// <param name="align"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="roi"></param>
/// <param name="maskROI"></param>
/// <param name="imageID"></param>
/// <param name="tileInfo"></param>
/// <returns></returns>
[UnmanagedFunctionPointerAttribute(CallingConvention::StdCall)]
public delegate IntPtr IplCreateImageHeader(int nChannels, int alphaChannel, int depth, 
											   IntPtr colorModel, IntPtr channelSeq, int dataOrder, int origin, int align, 
											   int width, int height, IntPtr roi, IntPtr maskROI, IntPtr imageID, IntPtr tileInfo);

/// <summary>
/// IplAllocateImageData
/// </summary>
/// <param name="image"></param>
/// <param name="doFill"></param>
/// <param name="fillValue"></param>
[UnmanagedFunctionPointerAttribute(CallingConvention::StdCall)]
public delegate void IplAllocateImageData(IntPtr image, int doFill, int fillValue);

/// <summary>
/// IplDeallocate
/// </summary>
/// <param name="image"></param>
/// <param name="flag"></param>
[UnmanagedFunctionPointerAttribute(CallingConvention::StdCall)]
public delegate void IplDeallocate(IntPtr image, int flag);

/// <summary>
/// IplCreateROI
/// </summary>
/// <param name="coi"></param>
/// <param name="xOffset"></param>
/// <param name="yOffset"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns></returns>
[UnmanagedFunctionPointerAttribute(CallingConvention::StdCall)]
public delegate IntPtr IplCreateROI(int coi, int xOffset, int yOffset, int width, int height);

/// <summary>
/// IplCloneImage
/// </summary>
/// <param name="img"></param>
/// <returns></returns>
[UnmanagedFunctionPointerAttribute(CallingConvention::StdCall)]
public delegate IntPtr IplCloneImage(IntPtr img);

/// <summary>
/// LoadImageFunc
/// </summary>
/// <param name="filename"></param>
/// <param name="colorness"></param>
/// <returns></returns>
[UnmanagedFunctionPointerAttribute(CallingConvention::Cdecl)]
public delegate IntPtr LoadImageFunc(IntPtr filename, int colorness);

/// <summary>
/// LoadImageMFunc
/// </summary>
/// <param name="filename"></param>
/// <param name="colorness"></param>
/// <returns></returns>
[UnmanagedFunctionPointerAttribute(CallingConvention::Cdecl)]
public delegate IntPtr LoadImageMFunc(IntPtr filename, int colorness);

/// <summary>
/// SaveImageFunc
/// </summary>
/// <param name="filename"></param>
/// <param name="image"></param>
/// <param name="paramsPtr"></param>
/// <returns></returns>
[UnmanagedFunctionPointerAttribute(CallingConvention::Cdecl)]
public delegate int SaveImageFunc(IntPtr filename, IntPtr image, IntPtr paramsPtr);

/// <summary>
/// ShowImageFunc
/// </summary>
/// <param name="windowname"></param>
/// <param name="image"></param>
[UnmanagedFunctionPointerAttribute(CallingConvention::Cdecl)]
public delegate void ShowImageFunc(IntPtr windowname, IntPtr image );
//////////////////////////////////////////////////////////////////////////
NAMESPACE_END
//////////////////////////////////////////////////////////////////////////